<?php
require_once 'Artdepot/Controller/Action.php';

class ArtistsController extends Artdepot_Controller_Action
{

    public function init()
    {
		parent::init();
    }

    public function indexAction()
    {
    	//advertisements here
    	$adTable = new Model_DbTable_Advertisement(); 
	    $this->view->ads = $adTable->fetchAll("position = 1 and enabled = 1", "display_order ASC");
	    
        $db = Zend_Db_Table_Abstract::getDefaultAdapter();
        $this->view->artists = $artists = $db->fetchAll("select * from artist order by name");
    }

    public function showAction()
    {
    	$id = intval($this->_getParam('id', 0));
    	if (empty($id)) {
    		$this->error('Artist not found.');
    		return;
    	}
    	
    	//advertisements here
    	$adTable = new Model_DbTable_Advertisement(); 
	    $this->view->ads = $adTable->fetchAll("position = 0 and enabled = 1", "display_order ASC");
	    
        $artistsTable = new Model_DbTable_Artist();
        $this->view->artist = $artist = $artistsTable->find($id)->current();
        $this->view->title = $artist->name . ' - ';
        $artworksModel = new Model_DbTable_ArtWork();
        $this->view->artworks = $artworksModel->fetchAll("artist=$id", 'id desc', 4);
        $this->view->criticises = $artist->getCriticises();
        $scoreTable = new Model_DbTable_ArtistScoreHistory();
        $this->view->scores = $scoreTable->fetchAll("artist=$id");
    }

    public function interviewAction()
    {
       $id = intval($this->_getParam('id', 0));
    	if (empty($id)) {
    		$this->error('Artist not found.');
    		return;
    	}
        $artistsTable = new Model_DbTable_Artist();
        $this->view->artist = $artist = $artistsTable->find($id)->current();
        $this->view->title = $artist->name . ' - Interview - ';
    }
    
    public function listInterviewAction(){
    	$table = new Model_DbTable_Artist();
    	$interviews = $table->fetchAll("famous = 1");
    	$this->view->interviews = $interviews;
    }


}





